package com.hx.study.service.impl;

import java.util.List;

import com.hx.common.annotation.DataScope;
import com.hx.common.utils.DateUtils;
import com.hx.study.domain.UserPaper;
import com.hx.study.mapper.UserPaperMapper;
import com.hx.study.service.IUserPaperService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 用户试卷Service业务层处理
 *
 * @author user
 * @date 2022-06-06
 */
@Service
public class UserPaperServiceImpl implements IUserPaperService {
    @Autowired
    private UserPaperMapper userPaperMapper;

    /**
     * 查询用户试卷
     *
     * @param id 用户试卷主键
     * @return 用户试卷
     */
    @Override
    public UserPaper selectUserPaperById(Integer id) {
        return userPaperMapper.selectUserPaperById(id);
    }

    /**
     * 查询用户试卷列表
     *
     * @param userPaper 用户试卷
     * @return 用户试卷
     */
    @Override
    @DataScope(userAlias = "u")
    public List<UserPaper> selectUserPaperList(UserPaper userPaper) {
        return userPaperMapper.selectUserPaperList(userPaper);
    }

    /**
     * 新增用户试卷
     *
     * @param userPaper 用户试卷
     * @return 结果
     */
    @Override
    public int insertUserPaper(UserPaper userPaper) {
        userPaper.setCreateTime(DateUtils.getNowDate());
        return userPaperMapper.insertUserPaper(userPaper);
    }

    /**
     * 修改用户试卷
     *
     * @param userPaper 用户试卷
     * @return 结果
     */
    @Override
    public int updateUserPaper(UserPaper userPaper) {
        userPaper.setUpdateTime(DateUtils.getNowDate());
        return userPaperMapper.updateUserPaper(userPaper);
    }

    /**
     * 批量删除用户试卷
     *
     * @param ids 需要删除的用户试卷主键
     * @return 结果
     */
    @Override
    public int deleteUserPaperByIds(Integer[] ids) {
        return userPaperMapper.deleteUserPaperByIds(ids);
    }

    /**
     * 删除用户试卷信息
     *
     * @param id 用户试卷主键
     * @return 结果
     */
    @Override
    public int deleteUserPaperById(Integer id) {
        return userPaperMapper.deleteUserPaperById(id);
    }
}
